package com.tuyrt.hi.library.app.demo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import com.tuyrt.hi.library.app.R
import com.tuyrt.hi.library.app.User
import com.tuyrt.hi.library.log.*

class HiLogDemoActivity : AppCompatActivity() {

    var viewPrinter: HiViewPrinter? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_hi_log_demo)
        viewPrinter = HiViewPrinter (this)
        findViewById<Button>(R.id.btn_log).setOnClickListener {
            printLog()
        }

        viewPrinter!!.viewProvider.showFloatingView()
    }

    private fun printLog() {
        HiLogManager.getInstance().addPrinter(viewPrinter)
        HiLog.log(object : HiLogConfig() {
            override fun includeThread(): Boolean {
                return true
            }

            override fun stackTraceDepth(): Int {
                return 0
            }
        }, HiLogType.E, "-----", "5556")

        HiLog.a("9900")
        HiLog.a(User("Jack", 18))
    }
}